from pymongo import MongoClient
import pandas as pd
client = MongoClient(port=27017)
db=client['tiktok']

#for col in db.list_collection_names():
#for col in ['rnbvibes','']:
collist=['2018vs2021']
for col in collist:
    t=0
    img=0
    text=0
    yam=0
    label=0
    v=0
    for obj in db[col].find():
        t+=1
        if not (len(obj['video_feature']['img_embed']) > 0):
            img+=1
        if not (len(obj['text_feature']['text'])>0 ):
            text+=1
        if not (len(obj['video_feature']['audio']['yamnet'])>0 ):
            yam+=1
        if not ((len(obj['video_feature']['label'])>0)and (len(obj['video_feature']['residual'])>0) and('labelA_n' in obj['video_feature']['label'].keys())) :
            label+=1
        if not(('var_sb' in obj['video_feature']['editing'].keys()) and ('avg_sticker_length' in obj['video_feature']['editing'].keys()) and ('avg_scences' in obj['video_feature']['editing'].keys())):
            v+=1
    print(col)
    print('img pct:',img,t,img/t)
    print('text pct:', text, t, text / t)
    print('yamnet pct:', yam, t, yam / t)
    print('label pct:', label, t, label / t)
    print('var pct:', v, t, v / t)